from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome()

driver.get("https://so.gushiwen.cn/user/login.aspx")

driver.get_screenshot_as_file("test.png")
x = 0
for i in range(1, 4):
    driver.get_screenshot_as_file("img/test{}.png". format(i))
    print("拍照结束")
    driver.execute_script("window.scrollTo(0, {})".format(i * 300))

driver.find_element_by_id("email").send_keys("18338328140")
driver.find_element_by_id("pwd").send_keys("sy920920")
time.sleep(5)
driver.find_element_by_id("denglu").click()

search_ele = driver.find_element_by_id("txtKey")
search_ele.send_keys("春江花月夜")
time.sleep(2)
search_ele.send_keys(Keys.ENTER)


driver.find_element(By.XPATH, "//div[@class='shoucang']/img[1]").click()

time.sleep(2)

driver.find_element(By.XPATH, "//div[@class='son1']/a[6]").click()
